Declaring variables

How to declare →variables within a →graphical editor:

  1. Make the list of declared variables visible. 
    Alternative for an →input variable, →output variable or →in-/out variableOpen the interface editor for the object (from within the project explorer). 

  2. From the context menu, select New Variable... Alternative: Press the Ctrl-key and the +-key.

  3. In the dialog, enter the following properties for the variable and click OK.

    1. name – The name must be an →IEC-identifier
      (info)  If you want to declare several variables in one go, enter the name with , separating the names. Example: UpErr, QuitErr, MotorUp, MotorDown 

    2. section (= the variable section), e.g. LOCAL (for →local variable, also known as →internal variable), INPUT (for →input variable) etc.

      Restrictions

      →Temporary variables are not possible in FBD. →In-out variables cannot be declared in a →program, →global variables cannot be declared in a →function block or →function

  1. →data type or →function block type
    (warning) Multi-dimensional array data types are not supported for connecting to a block in-/output with a →generic data type (e.g. the in-/output of the MOVE block). 
    (info) Enter one or several letters so that a selection list with the corresponding data types and function blocks is provided.
    Subsequent changes to the selection are possible, e.g. by completing an →ARRAY declaration. For the STRING data type, STRING[80] is automatically entered. Overwrite 80, if you need a different length for the STRING variable.  

  2. →initial value (only optional required) – This initial value may be a →constant expression (in compliance with the →data type).
    It is not possible to assign an initial value to an →external variable 

Good to know

(grey lightbulb) The application navigator provides the possibility to declare external variables and to have the declarations based on the already existing global variables. This is done when you drag the global variables from a global-object onto a →POU. Details: See "Declaring external variables by dragging and dropping global variables into POUs".

(grey lightbulb) Other possibilities to declare variables are listed under "Declaring variables in FBD" and "Declaring variables in LD and assigning a variable to contact/coil".